# Maintainer: Noel Kuntze <noel.kuntze@contauro.com>
pkgname=jicofo
pkgver=1.0.1062
_tag="jitsi-meet_9220"
pkgrel=0
pkgdesc="Jitsi meet conference focus"
url="https://github.com/jitsi/jicofo"
arch="x86_64 aarch64 s390x"
license="Apache-2.0"
options="!check" # No test suite
depends="openjdk11-jre-headless prosody bash"
makedepends="maven"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/jitsi/jicofo/archive/refs/tags/stable/$_tag.tar.gz
	$pkgname.initd
	$pkgname.conf
	$pkgname.confd
	$pkgname.logrotate
	sip-communicator.properties
	"

builddir="$srcdir/$pkgname-stable-$_tag"

build() {
	export JAVA_HOME=/usr/lib/jvm/java-11-openjdk
	export PATH=$JAVA_HOME/bin:$PATH
	mvn clean
	mvn -DskipTests -Dassembly.skipAssembly=true -Dmaven.repo.local="$builddir/.m2/repository" clean package install
	mvn dependency:copy-dependencies -DincludeScope=runtime -Dmaven.repo.local="$builddir/.m2/repository"
}

package() {
	DESTDIR="$pkgdir"/usr/lib/$pkgname
	CONFDIR="$pkgdir"/etc/jitsi/jicofo

	# dependencies, libraries and java launch files
	#install -Dm644 -t "$DESTDIR"/lib ./*/target/dependency/*
	install -Dm644 -t "$DESTDIR"/lib jicofo/target/dependency/*
	install -Dm644 jicofo/target/jicofo*.jar "$DESTDIR"/jicofo.jar
	install -Dm755 -t "$DESTDIR" resources/jicofo.sh
	install -Dm755 -t "$DESTDIR" resources/collect-dump-logs.sh

	# configuration
	install -dm755 "$CONFDIR"
	install -Dm644 "$srcdir/jicofo.conf" "$CONFDIR/jicofo.conf"
	install -Dm640 "$srcdir"/sip-communicator.properties "$CONFDIR/sip-communicator.properties"
	install -Dm644 -t "$CONFDIR" "lib/logging.properties"

	# init scripts and logrotate
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm640 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.logrotate "$pkgdir"/etc/logrotate.d/$pkgname
}

sha512sums="
df61ec1065dfb39c53b329bd2a1ac49232e03a75d91f800d8cad31b1f1e07f962c6b464e9908c8291284f522d3e592af0a9ae0a40f03aed784322e1dcc8ab419  jicofo-1.0.1062.tar.gz
d8a5a2bdde124d6e8aff7d1d26c68146ef3cc8fac988360486dcd86e3247a7cfcc311ba9a4b8e64c04524511db350ad98ad4bb6e7aa1b19162b0231d2b57d40a  jicofo.initd
2e0f56e6d68edf6250714274cd8f0bcaf150b8c0f2dbdece9e97873e0fcf2e6520800f329f7d9407266cd28414523b873c159e2c32336464633b03d9608b8109  jicofo.conf
f99851031af2a88590b4970106bc27cf8d5f7555f82e4c34bd33498904b36bff7efa1c85e5f2ca778a6f0e19cbe2fdd8bfc9357920f990c4b7c532c768d05cf7  jicofo.confd
64f34dafc1062187485671a29fa147d651c050d9b52331c2933c6c3f024654cd02961d40b1d178e70d2cac9107be4f881654be871423c27459ef6669bcd5402c  jicofo.logrotate
4d87dce61ab19920f9b790ddf52aa8057f17ad0657a5a763efeebd5df2bd51758baffd5167355421ccd9e21b4e87fbaac6210f11e4c31d6beb0a890ea3ff2486  sip-communicator.properties
"
